import FormField from '@src/component/form/FormField';
import { FieldTypeMappingEnum } from '@model/enum/FieldMappingEnum';
// @ts-ignore
import { randomString } from 'pub-bbx-utils';
import i18n from '@src/locales';
import { getCommonDefaultLangForKey } from '@src/util/languages'
const BASE_SETTING = {
    show: false,
    parentFormType: 'idcard' 
}

const feilds = [
    {
        displayName: i18n.t('common.base.fullName'),
        placeHolder: i18n.t('common.placeholder.input2'),
        fieldName: `field_${randomString(16)}_name`,
        formType: FieldTypeMappingEnum.IdCard,
        maxlength: 20,
        isNull: 0,
        setting: { ...BASE_SETTING, show: true }
    },
    {
        displayName: i18n.t('customer.idCard.iDNo'),
        formType: FieldTypeMappingEnum.Text,
        fieldName: `field_${randomString(16)}_number`,
        placeHolder: i18n.t('common.placeholder.input2'),
        maxlength: 100,
        isNull: 0,
        setting: { ...BASE_SETTING, show: true }
    },
    {
        displayName: i18n.t('common.base.sex'),
        formType: FieldTypeMappingEnum.Select,
        fieldName: `field_${randomString(16)}_sex`,
        setting: {
            ...BASE_SETTING ,
            dataSource : ["男", "女"],
            dataSourceLanguage: getCommonDefaultLangForKey('common.base.gender'),
            isMulti: false
        }
    },
    {
        displayName: i18n.t('customer.idCard.nation'),
        formType: FieldTypeMappingEnum.Text,
        fieldName: `field_${randomString(16)}_ethnicity`,
        placeHolder: i18n.t('common.placeholder.input2'),
        setting: { ...BASE_SETTING }
    },
    {
        displayName: i18n.t('customer.idCard.dateOfBirth'),
        formType: FieldTypeMappingEnum.Date,
        fieldName: `field_${randomString(16)}_birth`,
        setting: { ...BASE_SETTING }
    },
    {
        displayName: i18n.t('common.base.address'),
        formType: FieldTypeMappingEnum.Text,
        placeHolder: i18n.t('common.placeholder.input2'),
        fieldName: `field_${randomString(16)}_address`,
        maxlength: 100,
        setting: { ...BASE_SETTING }
    },
    {
        displayName: i18n.t('customer.idCard.signingAndIssuingOrganization'),
        formType: FieldTypeMappingEnum.Text,
        placeHolder: i18n.t('common.placeholder.input2'),
        fieldName: `field_${randomString(16)}_issue`,
        setting: { ...BASE_SETTING }
    },
    {
        displayName: i18n.t('customer.idCard.validFrom'),
        formType: FieldTypeMappingEnum.Date,
        fieldName: `field_${randomString(16)}_validFrom`,
        setting: { ...BASE_SETTING }
    },
    {
        displayName: i18n.t('customer.idCard.expiryDate'),
        formType: FieldTypeMappingEnum.Date,
        fieldName: `field_${randomString(16)}_validTo`,
        setting: { ...BASE_SETTING }
    },
    {
        displayName: i18n.t('customer.idCard.iDCardPhoto'),
        limit: 2,
        formType: FieldTypeMappingEnum.Attachment,
        setting: { ...BASE_SETTING, maxFileCount: 2 }
    }
]


export const formFields = ()=> feilds.map(field=> new FormField(field))